home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / GRAHAM / XAAES_S.ZIP / XAAES / MOUSE_CL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-01  |  2.5 KB  |  90 lines

  1. /*
  2.  * XaAES - XaAES Ain't the AES
  3.  *
  4.  * A multitasking AES replacement for MiNT
  5.  *
  6.  */
  7.  
  8. #include <MINTBIND.H>
  9. #include <OSBIND.H>
  10. #include <memory.h>
  11. #include "K_DEFS.H"
  12. #include "KERNAL.H"
  13. #include "XA_DEFS.H"
  14. #include "XA_TYPES.H"
  15. #include "XA_GLOBL.H"
  16. #include "MOUSE_CL.H"
  17. #include "EVNT_BTN.H"
  18. #include "C_WINDOW.H"
  19. #include "EVNT_MUL.H"
  20. #include "std_widg.h"
  21.  
  22. /*
  23.     Mouse button click handler 
  24.     - MOUSESRV sever process passes us click events
  25. */
  26.  
  27. /* The real button click handler is here :) */
  28. short XA_button_event(MOUSE_DATA *md)
  29. {
  30.     XA_CLIENT *client;
  31.     XA_WINDOW *w;
  32.     short kstate;
  33.     unsigned long retv=XA_OK;
  34.     short target_app=0;
  35.     
  36.     DIAGS(("MOUSE_CLICK EVENT: \n   loc=(%d,%d), state=%d, count=%d\n",md->mx,md->my,md->state, md->clicks));
  37.     
  38.     w=wind_find(md->mx, md->my);    /* Try for a window */
  39.     target_app=w->owner;
  40.     
  41.     if (mouse_lock)                    /* Mouse is locked - clicks go to owner of mouse */
  42.     {
  43.         target_app=mouse_lock;
  44.     }else{
  45.         if (update_lock)            /* Screen is locked - clicks go to owner of screen */
  46.         {
  47.             target_app=update_lock;
  48.         }
  49.     }
  50.     
  51.     if ((w)&&(w->owner==target_app))
  52.     {
  53.         if (do_widgets(w,md))
  54.             return FALSE;    /* Process window widgets */
  55.     }
  56.  
  57.     Psemaphore(2,CLIENTS_SEMAPHORE,-1L);
  58.  
  59.     client=Pid2Client(target_app);
  60.  
  61.     if (client->waiting_for&XAWAIT_BUTTON)    /* If the client owning was waiting for a button event, send it */
  62.     {                                        /* - otherwise forget it, 'coz we don't want delayed clicks (they are confusing to the user [ie. me] ) */
  63.         vq_key_s(V_handle, &kstate);        /* get the current keyboard state */
  64.  
  65.         if (client->waiting_for&XAWAIT_MULTI)            /* If the client is waiting on a multi, the response is  */
  66.         {                                                /* slightly different to the evnt_button() response. */
  67.             client->waiting_pb->intout[0]=MU_BUTTON;
  68.             client->waiting_pb->intout[1]=md->mx;
  69.             client->waiting_pb->intout[2]=md->my;
  70.             client->waiting_pb->intout[3]=md->state;
  71.             client->waiting_pb->intout[4]=kstate;
  72.             client->waiting_pb->intout[6]=md->clicks;
  73.             cancel_evnt_multi(target_app);
  74.         }else{
  75.             client->waiting_pb->intout[0]=md->state;
  76.             client->waiting_pb->intout[1]=md->mx;
  77.             client->waiting_pb->intout[2]=md->my;
  78.             client->waiting_pb->intout[3]=md->clicks;
  79.             client->waiting_pb->intout[4]=kstate;
  80.             client->waiting_for=0;            /* Now client isn't waiting for anything */
  81.         }
  82.         Fwrite(client->clnt_pipe_wr,sizeof(unsigned long),&retv);    /* Write success to clients reply pipe to unblock the process */
  83.     }
  84.  
  85.     Psemaphore(3,CLIENTS_SEMAPHORE,0L);
  86.  
  87.     return FALSE;
  88. }
  89.  
  90.